<template>
  <span>
    {{ permission(auth) ? value : default_value }}
  </span>
</template>

<script setup name="dataAuthority">
import useCommonStore from "@/store/modules/common";
const commonStore = useCommonStore();
const attributes_auth = computed(() => {
  if (!commonStore.attributes_auth) {
    commonStore.getAttributesList();
  }
  return commonStore.attributes_auth || [];
});

const props = defineProps({
  auth: { type: String, default: "" },
  value: { type: [String, Number], default: "" },
  default_value: { type: [String, Number], default: "**" },
});

const permission = (val) => {
  return attributes_auth.value.some((i) => i.value === val);
};
</script>
